﻿using System;
using System.Collections.Generic;
using System.Text;
using TimberSmart.Business.Contracts;
using TimberSmart.Business.Infrustructure;
using TimberSmart.Data.Contracts;
using TimberSmart.Model.Security;

namespace TimberSmart.Business
{
    public class UserService : ServiceBase, IUserService
    {
        private ITimberSmartUow _uow;

        // Inject the UoW.
        public UserService(ITimberSmartUow uow)
        {
            _uow = uow;
        }

        public IEnumerable<Validation> Validate(User user)
        {
            return null;
        }

        public IResponse<User> FindAllUsers(IAuthToken token)
        {
            IResponse<User> response = new Response<User>();

            response.Data = _uow.UserRepository.FindAllUsers();

            response.Validation = null;

            return response;
        }

        public User FindUserByUsername(string username)
        {
            return _uow.UserRepository.FindUserByUsername(username);
        }

        public User FindUserByCredentials(string username, byte[] passwordHash)
        {
            return _uow.UserRepository.FindUserByCredentials(username, passwordHash);
        }

        public void AddUser(User user)
        {
            _uow.UserRepository.AddUser(user);
        }

        public void UpdateUser(User user)
        {
            _uow.UserRepository.UpdateUser(user);
        }

        public void DeleteUser(User user)
        {
            _uow.UserRepository.DeleteUser(user);
        }

        public void DeleteUser(int id)
        {
            _uow.UserRepository.DeleteUser(id);
        }

        // public void SetUserAsInactive(int UserId, bool active);
        // public void CreateNewUser(User user);
        // public IEnumerable<User> FindUsersByCompany(int CompanyId);
        // public bool ChangePasswordForUser(int userId, byte[] oldPasswordHash, byte[] newPasswordHash);
        // public void CreateNewRole(Role role);
    }
}
